<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="./static/css/bootstrap.min.css">
</head>

<body>
    <!-- 给一个容器 -->
    <div class="container">
        <div class="row text-center">
            <h1>学生信息管理系统</h1>
            <hr>

            <a href="/index.html" class="btn btn-success">首页</a>
            <a href="/add.html" class="btn btn-warning">添加</a>

            <br>
            <br>
        </div>

        <!-- col-md-8 中等屏幕的8  12 -->
            <div class="row">
                <div class="form-group col-md-5">
                    <label for="name">姓名</label>
                    <input type="text" name="name" value="" id="name" class="form-control">
                </div>
            </div>
            <div class="row">
                <div class="form-group col-md-5">
                    <label for="sex">性别</label>
                    <input type="text" name="sex" value="" id="sex" class="form-control">
                </div>
            </div>
            <div class="row">
                <div class="form-group col-md-5">
                    <label for="age">年龄</label>
                    <input type="text" name="age" id="age" value="" class="form-control">
                </div>
            </div>
            <div class="row">
                <div class="form-group col-md-5">
                    <label for="age">qq</label>
                    <input type="text" name="qq" id="qq" value="" class="form-control">
                </div>
            </div>
            <div class="row">
                <div class="text-center col-md-5">
                    <button type="" class="btn btn-success" id="edit">提交</button>
                    <button type="" class="btn btn-danger">重置</button>
                </div>
            </div>
    </div>
    <script src="./static/js/jquery.min.js"></script>
    <script>
        let id = location.href.split('=')[1]
        $.ajax({
            url: "/edit", //请求接口地址
            type: "get", //请求的方式
            data: {
                id: id
            },
            success: function (res) {
                $('#name').val(res.data[0].name)
                $('#sex').val(res.data[0].sex)
                $('#age').val(res.data[0].age)
                $('#qq').val(res.data[0].qq)
            },
        })

        $('#edit').on('click', () => {
            let name = $('#name').val()
            let sex = $('#sex').val()
            let age = $('#age').val()
            let qq = $('#qq').val()
            $.ajax({
                url: "/edits",
                type: "post",
                data: {
                    id:id,
                    name: name,
                    sex: sex,
                    age: age,
                    qq: qq
                },
                success: function (res) {
                    
                },
            })
        })
    </script>
</body>

</html>